package com.ffx.service.impl;

import com.ffx.mapper.StudentMapper;
import com.ffx.pojo.Student;
import com.ffx.service.StudentService;
import com.ffx.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @outhor fufeixiang
 * @date 2021-11-08
 */
public class StudentServiceImpl implements StudentService {
    private StudentMapper studentMapper;
    public StudentServiceImpl(){
        //1. 得到sqlsession
        SqlSession sqlSession = MyBatisUtil.getSqlSession(true);
        //2. 得到studentMapper
        studentMapper = sqlSession.getMapper(StudentMapper.class);

    }
    //1. 查询所有学生
    @Override
    public List<Student> findAll() {

        return studentMapper.findAll();
    }

    //2. 添加学生
    @Override
    public void insert(Student student) {

        studentMapper.insert(student);
    }

    //3. 修改学生
    @Override
    public void update(Student student) {

        studentMapper.update(student);
    }

    //4. 删除学生
    @Override
    public void delete(String sid) {

        studentMapper.delete(sid);
    }
}
